Skip to content

test(auth): run integ tests for #4254 device metadata inputUsername fix - #4263

Closed
harsh62 wants to merge 5 commits into
mainfrom
test/pr-4254-device-metadata-alias-username
Closed

test(auth): run integ tests for #4254 device metadata inputUsername fix#4263
harsh62 wants to merge 5 commits into
mainfrom
test/pr-4254-device-metadata-alias-username

Conversation

@harsh62

@harsh62 harsh62 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test-only mirror of #4254 (from paywithextend:fix/device-metadata-alias-username), pushed to this repo so integration tests can run against it. Do not merge — merge #4254 instead.

Description

Aligns every device-metadata keychain read (and the two deviceNotFound deletes) with the inputUsername used by the write in ConfirmDevice, across the SRP, challenge, and device-SRP flows:

  • VerifyPasswordSRP — read and the deviceNotFound delete now use inputUsername.
  • VerifySignInChallenge — both reads and the deviceNotFound delete now use challenge.inputUsername ?? username.
  • UserPoolSignInHelper — carries inputUsername ?? username into .initiateDeviceSRP.
  • VerifyDevicePasswordSRP — reads metadata with inputUsername; the outgoing request still sends username (the echoed value).

Nothing sent to Cognito changes semantically — only the keychain lookups moved to the value the metadata was written under.

Related to #4196, which fixed the write path but left the read paths keyed off the Cognito-echoed USERNAME (the sub on alias sign-in pools).

Purpose

Running the Auth integration test suite against these commits.

dmorrow and others added 5 commits July 22, 2026 19:35
…n-in

`ConfirmDevice` stores device metadata under `signedInData.inputUsername`
(the username the caller signed in with), but the sign-in flow read it back
using `parameters["USERNAME"]` — the value Cognito echoes, which is the sub
for pools configured with alias sign-in.

On those pools the read never matched the write, so `DEVICE_KEY` was omitted
from the password-verifier response. Cognito treated every sign-in as a new
device: it returned fresh `NewDeviceMetadata`, `ConfirmDevice` stored it under
the email again, and the next sign-in repeated the cycle — MFA on every
sign-in and a new device record per attempt (one user had accumulated 50).

Pools where the username *is* the email are unaffected, since the two values
coincide there.

Reads now use the same value as the write:
- VerifyPasswordSRP: `inputUsername`
- VerifySignInChallenge (both call sites): `challenge.inputUsername ?? username`

Nothing sent to Cognito changes — `username` still supplies `USERNAME` on
every request; only the keychain lookups moved.

Known gap: the DeviceSRP actions (InitiateAuthDeviceSRP,
VerifyDevicePasswordSRP) still look up by the echoed username. That path only
executes once Cognito starts accepting the device key, so it is now reachable
and tracked separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Commit 122689e changed the sign-in flow to read device metadata with the
caller's `inputUsername` (matching how `ConfirmDevice` writes it), but left the
`deviceNotFound` recovery paths deleting under `username` — the value Cognito
echoes, which is the sub for pools with alias sign-in.

When a stored device key is stale, Cognito rejects the password verifier with
`ResourceNotFoundException`. The recovery path then deletes the wrong keychain
entry, leaving the real one in place, so the retry re-reads the same stale key,
Cognito rejects it again, and sign-in loops indefinitely.

Read and delete now use the same value in both actions:
- VerifyPasswordSRP: `inputUsername`
- VerifySignInChallenge: `challenge.inputUsername ?? username`

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Once a device is remembered, Cognito answers the password verifier with
DEVICE_SRP_AUTH instead of an MFA challenge, routing sign-in through
InitiateAuthDeviceSRP / VerifyDevicePasswordSRP. Both looked the stored device
metadata up by the Cognito-echoed username (the sub, on pools with alias
sign-in) rather than the `inputUsername` it was written under, so the lookup
missed and the request omitted DEVICE_KEY — Cognito then rejected sign-in with
"Missing required parameter DEVICE_KEY".

- UserPoolSignInHelper: carry `inputUsername ?? username` into `.initiateDeviceSRP`
  so InitiateAuthDeviceSRP reads (and re-sends) under the right key.
- VerifyDevicePasswordSRP: read metadata with `inputUsername`; the request still
  sends `username` (the echoed value), which is what Cognito expects.

Completes the alias-pool device-remembering fix (see prior two commits); the
DEVICE_SRP_AUTH path is only reachable once DEVICE_KEY is accepted, so it could
not be exercised until the earlier read/delete fixes landed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 14:48 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 15:56 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 15:56 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 15:56 — with GitHub Actions Inactive
@harsh62
harsh62 temporarily deployed to IntegrationTest August 4, 2026 15:56 — with GitHub Actions Inactive
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.96%. Comparing base (a7c45dc) to head (98d48b1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...SignIn/DeviceSRPAuth/VerifyDevicePasswordSRP.swift 0.00% 5 Missing ⚠️
...hPlugin/Actions/SignIn/VerifySignInChallenge.swift 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4263      +/-   ##
==========================================
+ Coverage   66.83%   66.96%   +0.13%     
==========================================
  Files        1170     1170              
  Lines       44539    44565      +26     
==========================================
+ Hits        29768    29845      +77     
+ Misses      14771    14720      -51     
Flag Coverage Δ
API_plugin_unit_test 68.36% <ø> (ø)
AWSPluginsCore 68.07% <ø> (ø)
Amplify 47.47% <ø> (-0.11%) ⬇️
Amplify_Foundation_Bridge_unit_test 62.28% <ø> (ø)
Amplify_Foundation_unit_test 67.64% <ø> (ø)
Analytics_plugin_unit_test 83.43% <ø> (ø)
Auth_plugin_unit_test 72.46% <82.85%> (-0.11%) ⬇️
Connect_unit_test 42.95% <ø> (ø)
DataStore_plugin_unit_test 82.77% <ø> (+1.10%) ⬆️
EventEnrichment_unit_test 88.98% <ø> (ø)
Firehose_plugin_unit_test 53.15% <ø> (ø)
Geo_plugin_unit_test 73.39% <ø> (ø)
Kinesis_plugin_unit_test 52.17% <ø> (ø)
Logging_plugin_unit_test 64.86% <ø> (ø)
Predictions_plugin_unit_test 34.09% <ø> (ø)
PushNotifications_plugin_unit_test 84.58% <ø> (ø)
RecordCache_unit_test 76.40% <ø> (ø)
Storage_plugin_unit_test 78.67% <ø> (ø)
unit_tests 66.96% <82.85%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants